package org.swan.web.user.mapper;

import org.apache.ibatis.annotations.*;
import org.swan.web.user.bean.UserBean;
import java.util.List;
import java.util.Optional;


public interface UserMapper {
    @Insert("insert into user ( key , name , description , status , namespace_id ) VALUES ( #{key} , #{name} , #{description} , #{status} , #{namespaceId})")
    @Options(useGeneratedKeys = true,keyProperty = "userId")
    long add(UserBean ub);
    @Select("select * from user where user_id = #{id}")
    Optional<UserBean> getById(@Param("id") long id);
    @Update("update user set key = #{key} ,name = #{name} ,description = #{description} ,status = #{status}  where user_id = #{userId}  ")
    long updateById(UserBean UserBean);
    @Delete("delete from user where user_id = #{UserId}")
    long deleteById(@Param("UserId") long UserId);
    @Select("select * from user limit #{rows} offset #{offset}")
    List<UserBean> list(@Param("offset") int offset,@Param("rows") int rows);
}
